package com.dzl.operation.service.impl;

import com.dzl.constant.OperationConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dzl.base.service.BaseServiceImpl;
import com.dzl.operation.dao.OperationLogMapper;
import com.dzl.operation.pojo.WelfareOperationLog;
import com.dzl.operation.service.OperationLogService;

import java.util.Date;

/**
 * @Description:操作日志impl
 * @author liufan
 * @time:2021年4月24日 下午3:51:06
 */
@Service
public class OperationLogServiceImpl extends BaseServiceImpl<WelfareOperationLog> implements OperationLogService{

	@Autowired
	private OperationLogMapper mapper;

	@Override
	public void saveOrderReturnSuccess(Integer orderId, String content) {
		WelfareOperationLog operationLog = new WelfareOperationLog();
		operationLog.setRelationId(orderId);
		operationLog.setContent(content);
		operationLog.setType(OperationConstant.TypeEnum.RETURN_ORDER_SUCCESS.getType());
		operationLog.setCreateBy(OperationConstant.SYSTEM_USER);
		operationLog.setCreateTime(new Date());
		operationLog.setUpdateTime(new Date());
		mapper.insertSelective(operationLog);
	}

	@Override
	public void saveOrderReturnFail(Integer orderId, String content) {
		WelfareOperationLog operationLog = new WelfareOperationLog();
		operationLog.setRelationId(orderId);
		operationLog.setContent(content);
		operationLog.setType(OperationConstant.TypeEnum.RETURN_ORDER_FAIL.getType());
		operationLog.setCreateBy(OperationConstant.SYSTEM_USER);
		operationLog.setCreateTime(new Date());
		operationLog.setUpdateTime(new Date());
		mapper.insertSelective(operationLog);
	}

	@Override
	public void saveBlueCharging(Integer orderId, String content) {
		WelfareOperationLog operationLog = new WelfareOperationLog();
		operationLog.setRelationId(orderId);
		operationLog.setContent(content);
		operationLog.setType(OperationConstant.TypeEnum.BLUE_CHARGING.getType());
		operationLog.setCreateBy(OperationConstant.SYSTEM_USER);
		operationLog.setCreateTime(new Date());
		operationLog.setUpdateTime(new Date());
		mapper.insertSelective(operationLog);
	}

	@Override
	public void saveOperationLog(Integer relationId, String content, Integer type, Integer createId, String createName) {
		WelfareOperationLog operationLog = new WelfareOperationLog();
		operationLog.setRelationId(relationId);
		operationLog.setContent(content);
		operationLog.setType(type);
		operationLog.setCreateBy(createId);
		operationLog.setCreateName(createName);
		operationLog.setCreateTime(new Date());
		operationLog.setUpdateTime(new Date());
		mapper.insertSelective(operationLog);
	}

}
